package com.rrd.dw.mr.gzip.kafka;

import com.ucredit.babel.common.model.BaseModel;
import com.ucredit.babel.common.model.RecordType;
import com.ucredit.babel.common.model.fahai.v1.PuDaoFaHaiSiFaListRecord;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper.Context;

import java.io.IOException;

/**
 * 法海司法数据列表
 *
 * @author guoqiang
 */

public class PuDaoFaHaiSiFaListParse extends ParseBase {
    private Text val = new Text();
    private Text key = new Text();

    /**
     * 法海司法数据列表
     *
     * @param model
     * @throws IOException
     * @throws InterruptedException
     */
    @Override
    public boolean parseJob(Context context, BaseModel<?> model, String successful) throws IOException, InterruptedException {
        PuDaoFaHaiSiFaListRecord obj = (PuDaoFaHaiSiFaListRecord) model;
        StringBuilder sb = getBaseInfo(obj, successful);

        StringBuilder TxSb = new StringBuilder(500);
        sb.append(formatValue(obj.getMsg())).append(CRT001);
        sb.append(formatValue(obj.getCode())).append(CRT001);
		TxSb.append(formatValue(obj.getSearchSeconds())).append(CRT001);
		TxSb.append(formatValue(obj.getPageNo())).append(CRT001);
		TxSb.append(formatValue(obj.getRange())).append(CRT001);
		TxSb.append(formatValue(obj.getTotalCount())).append(CRT001);
		TxSb.append(formatValue(obj.getTotalPageNum())).append(CRT001);
		TxSb.append(formatValue(obj.getFyggPageNum())).append(CRT001);
		TxSb.append(formatValue(obj.getFyggCount())).append(CRT001);
		TxSb.append(formatValue(obj.getAjlcPageNum())).append(CRT001);
		TxSb.append(formatValue(obj.getAjlcCount())).append(CRT001);
		TxSb.append(formatValue(obj.getShixinPageNum())).append(CRT001);
		TxSb.append(formatValue(obj.getShixinCount())).append(CRT001);
		TxSb.append(formatValue(obj.getZxggPageNum())).append(CRT001);
		TxSb.append(formatValue(obj.getZxggCount())).append(CRT001);
		TxSb.append(formatValue(obj.getCpwsPageNum())).append(CRT001);
		TxSb.append(formatValue(obj.getCpwsCount())).append(CRT001);
		TxSb.append(formatValue(obj.getKtggPageNum())).append(CRT001);
		TxSb.append(formatValue(obj.getKtggCount())).append(CRT001);
		TxSb.append(formatValue(obj.getBgtPageNum())).append(CRT001);
		TxSb.append(formatValue(obj.getBgtCount())).append(CRT001);
        StringBuilder txSb = getBaseInfo(obj);
        key.set(getKey());
        val.set((sb.toString() + TxSb + txSb).replace("\n", " ").replace("\r", " "));
        context.write(key, val);
        return true;
    }

    @Override
    public String getTableName() {
        return "kafka_babel_pu_dao_fa_hai_si_fa_list_inc";
    }

    @Override
    public String getType() {
        return RecordType.PD_FA_HAI_SI_FA_LIST_RECORD.toString();
    }

    @Override
    public String getSubType() {
        return ".list";
    }

    @Override
    public String getComment() {
        return "法海司法数据列表";
    }
}
